{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">付款日期</label>
        <div class="layui-input-block">
            <input id="c-date" lay-verify="required" data-date-type="date" class="datetime layui-input" name="row[date]" type="text" value="{:date('Y-m-d')}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">服务到期时间</label>
        <div class="layui-input-block">
            <input id="c-expire_time" lay-verify="required" data-date-type="date" class="datetime layui-input" name="row[expire_time]" type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">公司名称</label>
        <div class="layui-input-block">
            <input id="c-company" lay-verify="required" class=" layui-input" name="row[company]" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">合同金额</label>
        <div class="layui-input-block">
            <input id="c-total_money" lay-verify="required" class=" layui-input" step="0.01" name="row[total_money]" type="number">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">合同/发票</label>
        <div class="layui-input-block">
            <div class="layui-col-xs4">
                <input id="c-attachfiles" lay-verify="required" class=" layui-input" size="50" name="row[attachfiles]" type="text">
            </div>
            <button type="button" id="faupload-attachfiles" class="layui-btn faupload" data-input-id="c-attachfiles" data-type="file" data-multiple="true" data-preview-id="p-attachfiles"><i class="layui-icon layui-icon-upload"></i> 上传</button><button type="button" id="fachoose-attachfiles" class="layui-btn fachoose" data-input-id="c-attachfiles" data-multiple="true"><i class="iconfont icon-other"></i> 选择</button>
            <ul class="layui-row list-inline plupload-preview" id="p-attachfiles"></ul>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">支出金额</label>
        <div class="layui-input-block">
            <input id="c-pay_money" lay-verify="required" class=" layui-input" step="0.01" name="row[pay_money]" type="number">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">收入</label>
        <div class="layui-input-block">
            <input id="c-income" lay-verify="required" class=" layui-input" step="0.01" name="row[income]" type="number">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            {:Form::textarea('row[notes]','')}
        </div>
    </div>
    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use('yznForm', function() {
    var yznForm = layui.yznForm;
    yznForm.bindevent($("form.layui-form"));
});

$('#c-total_money').blur(function() {
    var total_money =  $('#c-total_money').val()
    var pay_money =  $('#c-pay_money').val()
    var income = Number(total_money) - Number(pay_money)
    if(total_money && pay_money){
        $('#c-income').val(income)
    }
});

$('#c-pay_money').blur(function() {
    var total_money =  $('#c-total_money').val()
    var pay_money =  $('#c-pay_money').val()
    var income = Number(total_money) - Number(pay_money)
    if(total_money && pay_money){
        $('#c-income').val(income)
    }
});
</script>
{/block}